﻿#ifndef FORMEKE_H
#define FORMEKE_H

#include <QMenu>
#include <QWidget>
#include <QStandardItemModel>
#include <src/dataCache/ekedatacache.h>
#include <Common/teststatusmodel.h>
#include <UserControl/CustomItemModel.h>
#include"Common/ekecase.h"
#include"Thread/eketestthead.h"
#include"dataCache/mvbprotocalcache.h"
#include"Tool/tcpcclientformvb.h"
namespace Ui {
class FormEKE;
}

class FormEKE : public QWidget
{
    Q_OBJECT

public:
    explicit FormEKE(QWidget *parent = nullptr);
    ~FormEKE();

    void initRightClickedMenu();
    void ShowEKEcase();
    bool ChildCaseTestUnit(QTcpSocket *client, const EKEChildCase &childCase, QString &resultInfo);
private slots:
    void on_btn_test_clicked();
    void on_btn_TestCaseImport_clicked();
    void on_btn_exportTestCase_clicked();
    void on_btn_run_clicked();
    void on_btn_pause_clicked();
    void on_btn_stop_clicked();
    void slotBtntestMVB();

    void slotThreadExit(int n); //线程退出
    void slotBtnResetAllPorts();
    void slotTransTcpMsg(const QString& msg);
    void slotConnectMVBSetver();
    void slotReceiveMvbData(QByteArray& mvbProtocalCache);
    void slotUpdateResult(const QString& testCaseNumber);       //更新结果显示
    void slotTestFunction();
    void slotTestEke();
    void showSingleCheckResult(const QString& TCNumber,bool bPass);
    void slotShowStatus();  //更新状态栏显示
    void updateStatusInfo_Process(int rcentID);    //更新状态栏进度信息
    void slotBtnTestClicked();      //状态栏测试按钮
    void slotBtnImportProtocalClicked();
    void slotShowProtoalData(const MVBProtocalCache& mvbProtocalCache);
    void slotOnModelDataChange(const QModelIndex &topLeft, const QVariant&value, const QVector<int> &roles);
signals:
    void SendLogMsg(const QString& logMsg,int ntype=0);
private:
    void connectAllSlots();
    void appendEKEcase(const EKECase& ekecase,QStandardItemModel* item);
    void ShowAllEKEcase(const QMap <QString,EKECase>& allCase);
private:
    Ui::FormEKE *ui;
    ekeDataCache _ekeDataCache;
    QString _OriginFile;
    QMenu *_menuRClick=nullptr;
    EKETestThead* _ekeThread = nullptr;
    TestStatusModel m_statusModel;
    MVBProtocalCache m_mvbProtoclaCache;
    tcpcClientForMVB m_clientForMVB;
    CustomItemModel *m_treeModel;
};

#endif // FORMEKE_H
